package cn.com.headfree.mouldshow.controller;

import cn.com.headfree.base.controller.ExBaseController;
import cn.com.headfree.base.controller.ResultData;
import cn.com.headfree.entity.isc.User;
import cn.com.headfree.mouldshow.service.ExportWordService;
import cn.com.headfree.mouldshow.service.HumanDataService;
import cn.com.headfree.mouldshow.service.ProveFileExportService;
import cn.com.headfree.util.WordExportUtil;
import cn.com.headfree.vo.simple.EmpBaseInfoVo;
import org.apache.commons.lang.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.ResourceLoader;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


@CrossOrigin("*")
@RestController
@RequestMapping(value = "/proveFileExport",produces = "application/json;charset=UTF-8")
public class ProveFileExportController extends ExBaseController {
    private static final Logger log = LogManager.getLogger(ProveFileExportController.class);

    @Autowired
    private ProveFileExportService proveFileExportService;
    /**
     * 佐证材料导出
     * @param request
     * @param response
     * @param sysCode
     * @param businessNode
     */
    @RequestMapping("/downloadAllFiles")
    public void downloadAllFiles(HttpServletRequest request, HttpServletResponse response, String sysCode,
                                 String businessNode) {
        ResultData rs = new ResultData();
        try {
            User user = this.getLoginUserInfo(request);
            proveFileExportService.downloadFiles(user.getFax(), sysCode, businessNode, request, response);
            log.info("下载附件成功！");
        } catch (Exception e) {
            rs.setSuccess(false);
            rs.setErrorMsg("下载附件失败！");
            e.printStackTrace();
        }
    }
}
